package com.dfbz.demo01;

import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo02_Deque集合 {

    public static void main(String[] args) {

        Deque<String> deque=new LinkedList<>();
        deque.addFirst("香蕉");
        deque.addFirst("栗子");
        deque.addFirst("草莓");
        deque.addFirst("西瓜");

        System.out.println(deque);

        Iterator<String> iterator = deque.descendingIterator();

        while (iterator.hasNext()){
            String fruit = iterator.next();
            System.out.println(fruit);
        }

    }

    public static void test(String[] args) {

        Deque<String> deque = new LinkedList<>();
        deque.offerFirst("石榴");
        deque.offerFirst("榴莲");
        deque.offerFirst("椰子");

        System.out.println(deque);
        String poll = deque.pollLast();
        System.out.println(poll);


    /*    deque.push("苹果");
        deque.push("香蕉");
        deque.push("西瓜");

        String pop = deque.pop();
        System.out.println(pop);
        System.out.println(deque);*/

       /* deque.addFirst("苹果");
        deque.addFirst("香蕉");

        System.out.println(deque);
        deque.addLast("西瓜");
        System.out.println(deque);*/
    }
}
